package com.eci.common.asset.custom;

import java.io.IOException;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * 	全局日期（针对 java.sql.Date、java.sql.Time、java.sql.TimeStamp三种）
 * jackson解析
 * */
public class CustomDateSerializer {
	
	
	 public static class SqlDateSerializer extends JsonSerializer<Date> {
		 
	        @Override
	        public void serialize(Date value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 
	            gen.writeString(value.toString());
	        }
	    }
	 public static  class TimestampSerializer extends JsonSerializer<Timestamp> {
		 
	       @Override
	       public void serialize(Timestamp value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 
	           gen.writeString(value.toString().substring(0, 19));
	       }
	   }
	   
	 public static  class SqlTimeSerializer extends JsonSerializer<Time> {
  
	       @Override
	       public void serialize(Time value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
	           
	           gen.writeString(value.toString());
	       }
	   }
	

}
